<template>
  <view class="container" v-if="!auth || JSON.stringify(auth) == '{}'">
    <u-empty mode="list" icon="http://cdn.uviewui.com/uview/empty/list.png">
    </u-empty>
  </view>
  <view class="container" v-else>
    <!-- 有登录的时候 -->
    <u-grid :border="true" col="2" align="center" :customStyle="GridStyle">
      <u-grid-item :customStyle="ItemStyle" @click="gopermission">
        <u-icon
          :customStyle="IconStyle"
          color="#19BC9C"
          size="40"
          name="google-circle-fill"
        />
        <text>权限管理</text>
      </u-grid-item>

      <u-grid-item :customStyle="ItemStyle" @click="product">
        <u-icon
          :customStyle="IconStyle"
          color="#005d8e"
          size="40"
          name="bag"
        />
        <text>手表管理</text>
      </u-grid-item>

  

      <u-grid-item :customStyle="ItemStyle" @click="recyclebin">
        <u-icon
          :customStyle="IconStyle"
          color="#ef0000"
          size="40"
          name="close-circle-fill"
        />
        <text>回收站</text>
      </u-grid-item>
      <u-grid-item :customStyle="ItemStyle" @click="shenpi">
        <view class="badge">
          <u-badge :type="'error'" max="99" :value="daishenpitotal"></u-badge>
        </view>
        <u-icon
          :customStyle="IconStyle"
          color="#676769"
          size="40"
          name="star"
        />
        <text>审批管理</text>
      </u-grid-item>
      <u-grid-item :customStyle="ItemStyle" @click="order">
        <view class="badge">
          <u-badge :type="'primary'" max="99" :value="daijiedantotal"></u-badge>
        </view>
        <u-icon
          :customStyle="IconStyle"
          color="#a46ef6"
          size="40"
          name="qzone-circle-fill"
        />
        <text>订单管理</text>
      </u-grid-item>
      <u-grid-item :customStyle="ItemStyle" @click="shouhou">
        <view class="badge">
          <u-badge
            :type="'warning '"
            max="99"
            :value="daishouhoutotal"
          ></u-badge>
        </view>
        <u-icon
          :customStyle="IconStyle"
          color="#3127fc"
          size="40"
          name="integral"
        />
        <text>售后管理</text>
      </u-grid-item>
      <u-grid-item :customStyle="ItemStyle" @click="feedback">
		<u-icon :customStyle="IconStyle" color="#008aac" size="40" name="man-add" />
		<text>反馈评价</text>
		</u-grid-item>
      <u-grid-item :customStyle="ItemStyle" @click="shop">
        <u-icon
          :customStyle="IconStyle"
          color="#b400aa"
          size="40"
          name="level"
        />
        <text>商城管理</text>
      </u-grid-item>
      <u-grid-item :customStyle="ItemStyle" @click="gsservices">
        <u-icon
          :customStyle="IconStyle"
          color="#131d3d"
          size="40"
          name="coupon"
        />
        <text>服务管理</text>
      </u-grid-item>
      <u-grid-item :customStyle="ItemStyle" @click="insure">
        <u-icon
          :customStyle="IconStyle"
          color="#696769"
          size="40"
          name="grid-fill"
        />
        <text>保险管理</text>
      </u-grid-item>
      <u-grid-item :customStyle="ItemStyle" @click="brank">
        <u-icon
          :customStyle="IconStyle"
          color="#00a5e1"
          size="40"
          name="moments"
        />
        <text>品牌管理</text>
      </u-grid-item>
      <u-grid-item :customStyle="ItemStyle" @click="store">
        <u-icon
          :customStyle="IconStyle"
          color="#d282d3"
          size="40"
          name="arrow-up-fill"
        />
        <text>门店管理</text>
      </u-grid-item>
      <u-grid-item :customStyle="ItemStyle" @click="memberlevel">
        <u-icon
          :customStyle="IconStyle"
          color="#fc4f27"
          size="40"
          name="calendar-fill"
        />
        <text>套餐管理</text>
      </u-grid-item>
      <u-grid-item :customStyle="ItemStyle" @click="businesslevel">
        <u-icon
          :customStyle="IconStyle"
          color="#2a532a"
          size="40"
          name="account"
        />
        <text>会员管理</text>
      </u-grid-item>

      <u-grid-item :customStyle="ItemStyle" @click="business">
        <u-icon
          :customStyle="IconStyle"
          color="#3c9cff"
          size="40"
          name="star-fill"
        />
        <text>用户管理</text>
      </u-grid-item>
      <u-grid-item :customStyle="ItemStyle" @click="seller">
        <u-icon
          :customStyle="IconStyle"
          color="#3c9cff"
          size="40"
          name="list-dot"
        />
        <text>卖家管理</text>
      </u-grid-item>
      <u-grid-item :customStyle="ItemStyle" @click="sellershenpi">
        <u-icon
          :customStyle="IconStyle"
          color="#5ac725"
          size="40"
          name="list-dot"
        />
        <text>卖家审批</text>
      </u-grid-item>

     
      <u-grid-item :customStyle="ItemStyle" @click="goodstype">
        <u-icon
          :customStyle="IconStyle"
          color="#2731fc"
          size="40"
          name="bag"
        />
        <text>商品分类管理</text>
      </u-grid-item>
  
    </u-grid>
    <u-toast ref="notice"></u-toast>
  </view>
</template>

<script>
export default {
  onLoad() {
    this.auth = uni.getStorageSync("auth") ? uni.getStorageSync("auth") : {};

    this.daishenpicount();
    this.daishouhoucount();
    this.daijiedan();
  },
  created() {
    this.timer = setInterval(() => {
      this.$u.count.check();
      this.daishenpicount();
      this.daishouhoucount();

      this.daijiedan();
    }, 15000);
  },



  data() {
    return {
      daishenpitotal: 0, //待审批总数
      daijiedantotal: 0, //待接单总数
      daishouhoutotal: 0,
      timer: "",
      qxrouter: {},
      GridStyle: {
        borderBottom: "1px solid #dadbde",
      },
      ItemStyle: {
        padding: "2em 0em",
      },
      IconStyle: {
        marginBottom: ".5em",
      },
      auth: {},
    };
  },
  methods: {
    // 待审批总数
    async daishenpicount() {
      let data = {
        adminid: this.auth.id,
        stoid: this.auth.stoid,
      };

      let result = await this.$u.api.depot.daishenpi(data);

      if (result.code) {
        this.daishenpitotal = result.data;
      }
    },

    // 待售后总数
    async daishouhoucount() {
      let data = {
        adminid: this.auth.id,
        stoid: this.auth.stoid,
      };

      let result = await this.$u.api.order.daishouhou(data);

      if (result.code) {
        this.daishouhoutotal = result.data;
      }
    },
    async daijiedan() {
      let data = {
        adminid: this.auth.id,
        stoid: this.auth.stoid,
      };
      let result = await this.$u.api.order.daijiedancount(data);
      if (result.code) {
        this.daijiedantotal = result.data;
      }
    },
    carpark() {
      uni.navigateTo({
        url: "/pages/business/carpark/index",
      });
    },
    shop() {
      uni.navigateTo({
        url: "/pagesB/shop/index",
      });
    },
    login() {
      this.$refs.notice.show({
        type: "error",
        message: "请先登录",
      });
    },
    bookingindex() {
      uni.navigateTo({
        url: "/pagesC/product/booking/index",
      });
    },
    product() {
      uni.navigateTo({
        url: "/pagesC/product/product/index",
      });
    },

    gopermission() {
      uni.navigateTo({
        url: "/pagesB/employee/permission/index",
      });
    },
    recyclebin() {
      uni.navigateTo({
        url: "/pagesD/recyclebin/index",
      });
    },

	blind(){
		uni.navigateTo({
        url: "/pagesC/product/blind/index",
      });

	},
	goodstype(){
		uni.navigateTo({
        url: "/pagesC/product/goodstype/index",
      });

	},
	seller(){
		uni.navigateTo({
        url: "/pages/business/business/index",
      });

	},
    shenpi() {
      uni.navigateTo({
        url: "/pagesC/shenpi/index",
      });
    },
    order() {
      uni.navigateTo({
        url: "/pagesB/order/index",
      });
    },
    shouhou() {
      uni.navigateTo({
        url: "/pagesB/order/shouhou/index",
      });
    },
    commission() {
      uni.$u.route({
        url: "/pagesA/admin/commission",
      });
    },
    feedback() {
      uni.navigateTo({
        url: "/pages/business/feedback/index",
      });
    },
    gsservices() {
      uni.navigateTo({
        url: "/pagesC/product/gsservices/servicetype/index",
      });
    },
    insure() {
      uni.navigateTo({
        url: "/pagesC/product/insure/index",
      });
    },
    brank() {
      uni.navigateTo({
        url: "/pagesC/product/brank/index",
      });
    },
    sellershenpi() {
      uni.navigateTo({
        url: "/pagesD/shenpi/index",
      });
    },
    addservices() {
      uni.navigateTo({
        url: "/pagesC/addservices/index",
      });
    },
    recharg() {
      uni.navigateTo({
        url: "/pagesA/admin/recharg",
      });
    },
    lights() {
      uni.navigateTo({
        url: "/pagesC/product/lights/index",
      });
    },
    store() {
      uni.navigateTo({
        url: "/pagesC/store/index",
      });
    },
    memberlevel() {
      uni.navigateTo({
        url: "/pagesD/level/index",
      });
    },
    businesslevel() {
      uni.navigateTo({
        url: "/pages/business/level/index",
      });
    },
    business() {
      uni.navigateTo({
        url: "/pages/business/carpark/index",
      });
    },
  },
};
</script>


<style scoped>
.badge {
  padding-left: 80px;
  padding-top: 15px;
}
</style>